28/11/2017

Data Visualization Using ggplot2

Overview of the Presentation

1. Introduction to Data Visualization

2. Introduction to ggplot

3. Overview of the Gapminder Dataset

4. Visualizing Gapminder

5. Extension libraries to ggplot2

Introduction to Data Visualization

What is Data Visualisation ?

Is is the visual representation of data for the purposes of :

  1. Decision making

  2. Communication Information

  3. Understanding your data

Role of Data Visualization

Data Visualization tools

Introduction to ggplot2

1. ggplot2 is a data visualization package for the statistical programming language R.

2. Created by Hadley Wickham in 2005

3. Implementation of Leland Wilkinson's Grammar of Graphics

4. Easy plotting with qplot function

5. Complex plotting with ggplot function

6. ggplot for python

Why ggplot2?

1. Free and open source

2. Professional quality graphs

3. Literate programming

4. Easy superpositioning (Multiple Plots in a graph)

5. Multiple themes + ggthemes

6. Large number of extension libraries

7. Tidyverse - R packages for Data Science

Gapminder DataFrame

country continent year lifeExp pop gdpPercap
Canada Americas 1952 68.75 14785584 11367.16
Canada Americas 1957 69.96 17010154 12489.95
Canada Americas 1962 71.30 18985849 13462.49
Canada Americas 1967 72.13 20819767 16076.59
Canada Americas 1972 72.88 22284500 18970.57
Canada Americas 1977 74.21 23796400 22090.88
Canada Americas 1982 75.76 25201900 22898.79
Canada Americas 1987 76.86 26549700 26626.52

Sample dataframe from 1704 records of the Gapminder dataset.

Gapminder Visualizations

GDP Per Capita in 1987 - Boxplot

GDP Per Capita in 1987 - Boxplot + Jitter Plot

Geographical plotting of GDP Per Capita in 2007

Contributions to Continent GDP in 2007 - Stacked Bar Plot

Life Expectancy in 1987 - Violin Plot

Life Expectancy in 1987 - Violin Plot + Jitter Plot

Life Expectancy Trends in Continents

African Life Expectancy in 1952 & 2007

Change in Life Expectancy in Africa - Bar Plot

Life Expectancy Trend in Continents

Life Expectancy in Africa in 2007 - Polar Bar Plot

GDP Per Capita Vs Life Expectancy in 2007

GDP Per Capita & Life Expectancy - Linear Model

GDP Per Capita & Life Expectancy - Non Linear Model

ggplot2 Extensions

Spatial Data - ggmap

Network Graphs - ggnet2

3D Plots - Plotly R Library

References